#ifndef eatableview_h
#define eatableview_h

#include "juce_amalgamated.h"
#include "../FoodObjects/Eatable.h"

class EatableView: public Component {
protected:
	Eatable* eatable;
	const static int spacer = 7;

	int getImageWidth() {
		return 4 * getWidth() / 7 - 2 * spacer;
	}

public:
	EatableView() :
		eatable(0) {
	}

	void paint(Graphics& g) {
		g.fillAll(Colour(240, 240, 250));
		g.setColour(Colours::grey);
		g.drawRect(0, 0, getWidth(), getHeight());
		Image* image = eatable->getImage();
		if (image != 0) {
			g.drawImage(image, spacer, spacer, getImageWidth(), getImageWidth(), 0, 0,
					image->getWidth(), image->getHeight(), false);
		}

		g.drawRect(spacer, spacer, getImageWidth(), getImageWidth());

		paintExtra(g);
	}

	/*
	 * The common code goes in the paint() method, specialized code per food
	 * item will go in this
	 */
	virtual void paintExtra(Graphics& g) = 0;

	void setEatable(Eatable* eatable) {
		this->eatable = eatable;
	}
};

#endif
